package com.juli.v2xdemo.tcp.protocol.bean;

import com.cz.basetool.CodeTool;

/**
 * Created by XinYi on 2019/5/22.
 * 周围车辆信息
 */
public class AroundCarInfoBean {
    private String originalData;
    private String VehichlInfo;
    private String VehiID;
    private String Latitude;
    private String Longitude;
    private String Lat_Long_Dir;
    private String Heading;
    private String Speed;
    private String AlertType;
    private String Description;
    private String lane;

    //nice read field
    private CarVehichlInfo carVehichlInfo;


    public AroundCarInfoBean(String originalData) {
        this.originalData = originalData;
        String[] items = CodeTool.splitStrings(originalData, 1, 8, 4, 4, 1, 2, 2, 2, 2,1);
        this.VehichlInfo = items[0];
        this.VehiID = items[1];
        this.Latitude = items[2];
        this.Longitude = items[3];
        this.Lat_Long_Dir = items[4];
        this.Heading = items[5];
        this.Speed = items[6];
        this.AlertType = items[7];
        this.Description = items[8];
        this.lane =  items[9];
        setCarVehichlInfo(new CarVehichlInfo(VehichlInfo));
    }

    public static class CarVehichlInfo{
        private  int carOwner ;             //车辆所有人；0，自身；非0，其他
        private  int warnInfo;              //预警信息
        private  int carType;               // 车辆类型；0，非紧急；1，紧急
        private  int carStatus;             //车辆状态；0，正常；1，故障
        private String VehichlInfo;

        public CarVehichlInfo(String vehichlInfo) {
            this.VehichlInfo = vehichlInfo;
            String result = CodeTool.oneByteHexNum2BinaryStr8(VehichlInfo);
            this.carOwner = CodeTool.hex2Int(CodeTool.binaryStr2HexStr(result.substring(0,1)));
            this.warnInfo = CodeTool.hex2Int(CodeTool.binaryStr2HexStr(result.substring(1,6)));
            this.carType = CodeTool.hex2Int(CodeTool.binaryStr2HexStr(result.substring(6,7)));
            this.carStatus = CodeTool.hex2Int(CodeTool.binaryStr2HexStr(result.substring(7,8)));
        }

        public int getCarOwner() {
            return carOwner;
        }

        public void setCarOwner(int carOwner) {
            this.carOwner = carOwner;
        }

        public int getWarnInfo() {
            return warnInfo;
        }

        public void setWarnInfo(int warnInfo) {
            this.warnInfo = warnInfo;
        }

        public int getCarType() {
            return carType;
        }

        public void setCarType(int carType) {
            this.carType = carType;
        }

        public int getCarStatus() {
            return carStatus;
        }

        public void setCarStatus(int carStatus) {
            this.carStatus = carStatus;
        }

        public String getVehichlInfo() {
            return VehichlInfo;
        }

        public void setVehichlInfo(String vehichlInfo) {
            VehichlInfo = vehichlInfo;
        }




        @Override
        public String toString() {
            return "CarVehichlInfo{" +
                    "carOwner=" + carOwner +
                    ", warnInfo=" + warnInfo +
                    ", carType=" + carType +
                    ", carStatus=" + carStatus +
                    ", VehichlInfo='" + VehichlInfo + '\'' +
                    '}';
        }
    }

    public String getVehichlInfo() {
        return VehichlInfo;
    }

    public void setVehichlInfo(String vehichlInfo) {
        VehichlInfo = vehichlInfo;
    }

    public String getVehiID() {
        return VehiID;
    }

    public void setVehiID(String vehiID) {
        VehiID = vehiID;
    }

    public String getLatitude() {
        return Latitude;
    }

    public void setLatitude(String latitude) {
        Latitude = latitude;
    }

    public String getLongitude() {
        return Longitude;
    }

    public void setLongitude(String longitude) {
        Longitude = longitude;
    }

    public String getLat_Long_Dir() {
        return Lat_Long_Dir;
    }

    public void setLat_Long_Dir(String lat_Long_Dir) {
        Lat_Long_Dir = lat_Long_Dir;
    }

    public String getHeading() {
        return Heading;
    }

    public void setHeading(String heading) {
        Heading = heading;
    }

    public String getSpeed() {
        return Speed;
    }

    public void setSpeed(String speed) {
        Speed = speed;
    }

    public String getAlertType() {
        return AlertType;
    }

    public void setAlertType(String alertType) {
        AlertType = alertType;
    }

    public String getDescription() {
        return Description;
    }

    public void setDescription(String description) {
        Description = description;
    }

    public CarVehichlInfo getCarVehichlInfo() {
        return carVehichlInfo;
    }

    public void setCarVehichlInfo(CarVehichlInfo carVehichlInfo) {
        this.carVehichlInfo = carVehichlInfo;
    }

    public String getLane() {
        return lane;
    }

    public void setLane(String lane) {
        this.lane = lane;
    }

    @Override
    public String toString() {
        return "AroundCarInfoBean{" +
                "originalData='" + originalData + '\'' +
                ", VehichlInfo='" + VehichlInfo + '\'' +
                ", VehiID='" + VehiID + '\'' +
                ", Latitude='" + Latitude + '\'' +
                ", Longitude='" + Longitude + '\'' +
                ", Lat_Long_Dir='" + Lat_Long_Dir + '\'' +
                ", Heading='" + Heading + '\'' +
                ", Speed='" + Speed + '\'' +
                ", AlertType_Byte2='" + AlertType + '\'' +
                ", Description='" + Description + '\'' +
                ", lane='" + lane + '\'' +
                ", carVehichlInfo=" + carVehichlInfo.toString() +
                '}';
    }
}
